const readlineSync = require('readline-sync');
const webpack = require('webpack');

let settingsName = process.argv[2];
console.log(settingsName)

if (!settingsName) {
  let buildEnv = process.ENV;

  if (buildEnv === 'production') {
    let answer = readlineSync.question('未检测到指定配置文件，将使用dev配置，是否确认？(Y / N)\r\n');
    if (!answer || answer.toUpperCase() !== 'Y') {
      process.exit()
    }
  }
}

if (!settingsName || settingsName.includes('--')) {
  settingsName = 'local'
}

const settings = require('../settings/settings-' + settingsName);

module.exports = new webpack.DefinePlugin({
  'SETTINGS': JSON.stringify(settings)
});
